/* 
* 科技有限公司版权所有（）.
* Copyright (c) 2019,   and/or its affiliates. All rights reserved.
* @Date: 2020.09.01 22:47.
* @Author 
* @Description  项目 - 订单详情
**/
<template>
  <div class="pr-detail">
    <h1 class="pr-title"> 商品消息 </h1>
    <ul class="pr-detail-list">
      <li><label>商品名称：</label>{{detail.commodity}}</li>
      <li><label>商品金额：</label>{{ detail.value || (detail.distributorGoodsPrice ? (detail.distributorGoodsPrice / 100) : '') }}</li>
      <li><label>商品ID：</label>{{detail.goodsId}}</li>
    </ul>

    <h1 class="pr-title"> 订单信息 </h1>
    <ul class="pr-detail-list">
      <li><label>订单号：</label>{{detail.orderId}}</li>
      <li><label>折扣金额：</label>{{detail.deduction}}元</li>
      <li><label>实付金额：</label>{{detail.pay}}</li>
      <li><label>创建时间：</label>{{detail.createTime}}</li>
      <li><label>支付状态：</label>{{payStatus(detail.payStatus)}}</li>
      <li><label>支付流水号：</label>{{detail.serialNumbser}}</li>
      <li><label>支付时间：</label>{{detail.payTime}}</li>
      <li><label>退款时间：</label>{{detail.checkTime}}</li>
    </ul>

    <h1 class="pr-title"> 核销信息 </h1>
    <ul class="pr-detail-list">
      <li><label>加汇码值：</label>{{detail.payNum}}</li>
      <li><label>核销状态：</label>{{ codeStatus(detail.codeStatus) }}</li>
      <li><label>关联时间：</label>{{detail.veriftyTime}}</li>
      <li><label>核销站点：</label>{{detail.petrolstationname}}</li>
      <li><label>核销时间：</label>{{detail.veriftyTime}}</li>
      <li><label>过期时间：</label>{{detail.validTime}}</li>
      <li><label>加油站编号：</label>{{detail.code}}</li>
      <li><label>加油站省市区：</label>{{detail.province}}{{detail.city}}{{detail.cityProper}}</li>

    </ul>

    <h1 class="pr-title"> 用户信息 </h1>
    <ul class="pr-detail-list">
      <li><label>用户手机号：</label>{{detail.phone}}</li>
      <li><label>openID：</label>{{detail.openId}}</li>
      <li><label>本月购买次数：</label>{{detail.monthNum}}次</li>
      <li><label>当天购买次数：</label>{{detail.dayNum}}/日</li>
    </ul>

    <el-button type="info" class="pr-back-block" @click="handleBackClick">返回</el-button>
  </div>
</template>
<script>
import dayjs from 'dayjs'
import urls from '@/api/urls'
import { getData, postData } from '@/api/'

export default {
  name: 'orderDetail',
  props: {},
  components: {},
  data() {
    return {
      detail: {}
    }
  },
  watch: {},
  created() {
    this.getDetail()
    console.log('this.$route.params.id-----', this.$route.params.id)
  },
  mounted() { },
  methods: {
    /**
     *@Description
     *@Return 详情.
     **/
    getDetail() {
      const url = `${urls.orderUrl}/${this.$route.params.id}`
      getData({ id: this.$route.params.id }, url).then(res => {
        this.detail = res.result
        this.getUserDetail(res.result.phone)
        console.log('详情--------', res)
      })
    },
    /**
     *@Description
     *@Return 获取用户 信息.
     **/
    getUserDetail(phone) {
      getData({ phone: phone }, urls.userInfoUrl).then(res => {
        this.detail = { ...this.detail, ...res.result }
        console.log('获取用户 信息--------', res)
      })
    },
    /**
     *@Description
     *@Return 返回.
     **/
    handleBackClick() {
      this.$router.push({ name: 'OrderList' })
    },
    payStatus(status) {
      if (status == '0') {
        return '已支付'
      } else if (status == '1') {
        return '待支付'
      } else if (status == '2') {
        return '已取消'
      } else if (status == '3') {
        return '退款中'
      } else if (status == '4') {
        return '退款成功'
      }
    },
    codeStatus(status) {
      if (status == '50') {
        return '已核销'
      } else if (status == '20') {
        return '待核销'
      } else if (status == '99') {
        return '已失效'
      }
    },
  }
}

</script>
<style lang="scss" scoped="scoped">
</style>
